package com.yanyeori.framework.storage.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * OSS Config
 *
 * @author chenkuan 2023/2/14
 */
@Configuration
@ConditionalOnProperty(name = "oss.endpoint")
public class OSSConfig {

    @Bean
    public OSS ossClient(OSSProperties ossProperties) {
        return new OSSClientBuilder().build(ossProperties.getHttp() + ossProperties.getEndpoint(), ossProperties.getAccessKeyId(), ossProperties.getAccessKeySecret());
    }
}
